package com.yxhl.zoume.domain.interactor.busticket;

import com.google.protobuf.GeneratedMessageV3;
import com.yxhl.protobuf.PubEndStationRequest;
import com.yxhl.protobuf.PubEndStationResponse;
import com.yxhl.zoume.data.http.repository.busticket.BusTicketRepository;
import com.yxhl.zoume.domain.DomainConstants;
import com.yxhl.zoume.domain.interactor.base.ProtoUseCase;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by vhawk on 16/3/20.
 */
public class GetArrivalCitiesUseCase extends ProtoUseCase<PubEndStationResponse> {

    private final BusTicketRepository repository;

    @Inject
    public GetArrivalCitiesUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                                   @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                                   BusTicketRepository repository) {
        super(uiThread, executorThread);
        this.repository = repository;
    }

    @Override
    protected Observable<PubEndStationResponse> buildObservable(GeneratedMessageV3 message) {
        return repository.getArrivalCities((PubEndStationRequest) message)
                .observeOn(uiThread)
                .subscribeOn(executorThread);
    }

}
